package com.jzlg.miniec.mapper;

import com.jzlg.miniec.entity.User;
import org.apache.ibatis.annotations.*;

/**
 * @Author StCat
 * @Date 2021/11/29 10:30
 * 全注解编程，用户管理
 */
@Mapper
public interface UserMapper {
    //用户登录
    @Select("select uid from user where username=#{username} and password=#{password}")
    Integer selectUserByNameAndPass(@Param("username") String username, @Param("password") String password);
    //用户注册
    @Insert("insert into user (username,password,nickname,last_update)"+
            "values(#{username},#{password},#{nickname},#{last_update})")


    //获取自动生成的id
    @Options(useGeneratedKeys = true,keyProperty ="uid")
    Integer insertUser(User user);
    //用户注册之前，要判断用户是否存在，查询用户名

    @Select("select uid from user where username=#{username}")
    Integer selectUserByName(@Param("username") String username);



}
